/**
 * @file DB0.c
 * @author your name (you@domain.com)
 * @brief 第0个数据块
 * @version 0.1
 * @date 2025-04-11
 *
 * @copyright Copyright (c) 2025
 *
 */
#include "DB0.h"
#include "global.h"
DB0_s *DB0_t = (DB0_s *)plc_DB[0]; /* DB0数据块结构体实例绑定到Plc_DB[0] */

// 初始化DB0，可根据需要修改
void init_DB0(void) {
  DB0_t->main_t.coils = 0xA5; // 10100101
  DB0_t->main_t.sensor.temperature = 0x1234;
  DB0_t->main_t.sensor.pressure = 12.34;
  DB0_t->main_t.switch_array[0] = 0x01;
  DB0_t->main_t.switch_array[1] = 0x02;
  DB0_t->main_t.switch_array[2] = 0x03;
  DB0_t->main_t.switch_array[3] = 0x04;
  DB0_t->main_t.counter = 0x56789ABC;
}
void loop_DB0(void) {
  DB0_t->main_t.coils ^= 0xFF;
  DB0_t->main_t.sensor.temperature += 1;
  DB0_t->main_t.sensor.pressure += 0.1;
  DB0_t->main_t.counter += 1;
}
